<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // import命令是编译阶段执行的，在代码运行之前。因此这意味着被导入的模块会先运行，而导入模块的文件会后执行。
        // index.js
        console.log('running index.js');
        import { sum } from './sum.js';
        console.log(sum(1, 2));

        // sum.js
        console.log('running sum.js');
        export const sum = (a, b) => a + b;

    </script>
</body>

</html>